package personal.xzhang.swing.jwizard;

import java.awt.BorderLayout;
import java.awt.Color;
import java.net.URL;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSeparator;

public abstract class JWizardStepPanel extends JPanel {

    private static final long serialVersionUID = 1L;
    
    private JPanel headerPanel_;
    private JLabel titleLabel_;
    private JLabel logoLabel_;
    
    private JPanel contentPanel_;
    
    private int nextStepIndex_;
    
    private int previousStepIndex_;
    
    public JWizardStepPanel() {
        super();
        init();
    }
    
    private void init() {
        setLayout(new BorderLayout());
        initHeaderPanel();
        add(headerPanel_, BorderLayout.NORTH);
        initContentPanel();
        add(contentPanel_, BorderLayout.CENTER);
    }
    
    private void initHeaderPanel() {
        headerPanel_ = new JPanel(new BorderLayout());
        headerPanel_.setBackground(Color.WHITE);
        headerPanel_.add(new JSeparator(), BorderLayout.SOUTH);
        titleLabel_ = new JLabel("");
        headerPanel_.add(titleLabel_, BorderLayout.CENTER);
        //headerPanel_.add(subTitleLabel_, BorderLayout.CENTER);
        URL url = getClass().getResource("logo.gif");
        logoLabel_ = new JLabel(new ImageIcon(url));
        headerPanel_.add(logoLabel_, BorderLayout.EAST);
    }
    
    private void initContentPanel() {
        contentPanel_ = new JPanel();
    }
    
    protected JPanel getContent() {
        return contentPanel_;
    }
    
    public void setTitle(String title) {
        titleLabel_.setText(title);
    }
    
    public void setLogo(Icon icon) {
        logoLabel_.setIcon(icon);
    }
    
    public int getNextStepIndex() {
        return nextStepIndex_;
    }
    
    public void setNextStepIndex(int index) {
        nextStepIndex_ = index;
    }
    
    public int getPreviousStepIndex() {
        return previousStepIndex_;
    }
    
    public void setPreviousStepIndex(int index) {
        previousStepIndex_ = index;
    }
}
